package com.sqx.modules.health.dto;/*
package com.sqx.modules.health.dto;

import cn.hutool.log.Log;
import com.github.wxpay.sdk.WXPayConstants;
import com.sqx.modules.health.config.WxConfig;
import com.sqx.modules.health.utils.WxUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.mapper.MappingData;
import org.apache.tomcat.util.modeler.BaseModelMBean;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

*/
/**
 * 封装请求数据的实体 ===> 封装发起微信支付时所需要的参数
 * @author gxy
 *//*

@Slf4j
@Data
public class ServiceOrderDTO extends BaseModelMBean {

    private String orderNumber;
    private Integer serviceId;
    private Integer versionNum;
    private BigDecimal amount;
    private LocalDateTime successTime;
    private String userIp;
    private String openId;
    private String body;
    private String key;

    public Map<String, String> toWxPayParameters() throws Exception {
        Map map = new HashMap();
        map.put("body", this.body);  // 商品名字
        map.put("appid", WxConfig.appId); // 小程序appid
        map.put("mch_id", WxConfig.mchId); // 商户id
        map.put("nonce_str", WxUtil.generateNonceStr()); // 随机字符串
        map.put("notify_url", WxConfig.notifyPath); // 回调地址
        map.put("openid", this.openId); // 发起微信支付的用户的openid
        map.put("out_trade_no", this.orderNumber); // 订单号
        map.put("spbill_create_ip", this.userIp); // 发起微信支付的用户的ip地址
        map.put("total_fee", parseAmount()); // 金额 （单位分）
        map.put("trade_type", WxConfig.tradeType); // 支付类型
        // 数据签名   也是第一次签名
        map.put("sign", WxUtil.generateSignature(map, WxConfig.key, WXPayConstants.SignType.MD5));
        return map;
    }

    public String parseAmount() {
        BigDecimal multiply = amount.multiply(BigDecimal.valueOf(100));
        BigDecimal result = multiply;
        if (multiply.compareTo(BigDecimal.valueOf(1)) == 0) {
            result = BigDecimal.valueOf(1);
        }
        return result.stripTrailingZeros().toPlainString();
    }

    @Override
    public String toString() {
        return "PrepaidOrderDTO{" +
                "orderNumber='" + orderNumber + '\'' +
                ", versionNum=" + versionNum +
                ", amount=" + amount +
                ", successTime=" + successTime +
                ", userIp='" + userIp + '\'' +
                ", openId='" + openId + '\'' +
                '}';
    }
}
*/
